package tech.aistar.corejava.day05.HomeWork;

public class PascalTriangle {
    public static void main(String[] args) {
        pascalTriangle(9);
    }
   
    public static void pascalTriangle(int n){
        /**
         * @Author:         lya
         * @Description:   本类的作用描述:打印杨辉三角
         * @param n     要打印的行数
         * @return:         void
         * @CreateDate:    2019/7/20 16:19
         * @Version:       1.0
        */
        int[][] arr = new int[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if(i == j || j == 0){
                    arr[i][j] = 1;
                }else{
                    arr[i][j] =  arr[i-1][j-1] + arr[i-1][j];
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print(arr[i][j]+"\t");
            }
            System.out.println();
        }
    }
}
